/**
 * @Author ZhangCuirong
 * @Date 2025/8/13 15:09
 * @description:
 */
public class Solution165 {
    public int compareVersion(String version1, String version2) {
        String[] v1 = version1.split("\\.");
        String[] v2 = version2.split("\\.");
        int length = Math.max(v1.length, v2.length);
        int index = 0;
        while (index < length) {
            int a = index >= v1.length ? 0 : Integer.parseInt(v1[index]);
            int b = index >= v2.length ? 0 : Integer.parseInt(v2[index]);
            if (a < b) {
                return -1;
            } else if (a > b) {
                return 1;
            }
            index++;
        }
        return 0;
    }

    public static void main(String[] args) {
        Solution165 solution = new Solution165();
        String version1 = "1.2";
        String version2 = "1.10";
        int res = solution.compareVersion(version1, version2);
        System.out.println(res);
    }
}
